package com.box.mapper;

import com.box.entity.ArticleAndArticleType;
import com.box.entity.DbArticle;
import com.box.entity.DbArticleExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface DbArticleMapper {
    int countByExample(DbArticleExample example);

    int deleteByExample(DbArticleExample example);

    int deleteByPrimaryKey(Integer arid);

    int insert(DbArticle record);

    int insertSelective(DbArticle record);

    List<DbArticle> selectByExampleWithBLOBs(DbArticleExample example);

    List<DbArticle> selectByExample(DbArticleExample example);

    DbArticle selectByPrimaryKey(Integer arid);

    int updateByExampleSelective(@Param("record") DbArticle record, @Param("example") DbArticleExample example);

    int updateByExampleWithBLOBs(@Param("record") DbArticle record, @Param("example") DbArticleExample example);

    int updateByExample(@Param("record") DbArticle record, @Param("example") DbArticleExample example);

    int updateByPrimaryKeySelective(DbArticle record);

    int updateByPrimaryKeyWithBLOBs(DbArticle record);

    int updateByPrimaryKey(DbArticle record);
    
    //列表页
   @Select("SELECT * FROM `db_article` a LEFT JOIN `db_articletype` ab ON ab.artid=a.artypeid WHERE a.artypeid=#{artypeid} AND a.isview=1 ORDER BY  a.arcreatetime DESC limit #{firstIndex},#{pageNum} ")
    List<ArticleAndArticleType> selArticleTypeAndArticle(@Param("artypeid") Integer artypeid,@Param("firstIndex") Integer firstIndex,@Param("pageNum") Integer pageNum);
   
   @Select("SELECT COUNT(*) FROM `db_article` a LEFT JOIN `db_articletype` ab ON ab.artid=a.artypeid WHERE a.artypeid=#{artypeid} AND a.isview=1")
   Long selCountArticleTypeAndArticle(@Param("artypeid") Integer artypeid);
    
   //点击相对应的id进入该对象 
   @Select("SELECT * FROM `db_article` a LEFT JOIN `db_articletype` ab ON ab.artid=a.artypeid WHERE a.arid=#{arid}")
   ArticleAndArticleType selObjectByArticleAndThisType(@Param("arid") Integer arid);
}